<head>
    <link href="${ctx}/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link href="${ctx}/font-awesome/3.0.0/css/font-awesome.min.css" rel="stylesheet">
    <link href="${ctx}/css/index.css" rel="stylesheet">
    <link href="${ctx}/bootstrap-table/1.12.0/bootstrap-table.min.css" rel="stylesheet">
    <script src="${ctx}/jquery/2.1.4/jquery.min.js"></script>
    <script src="${ctx}/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="${ctx}/bootstrap-table/1.12.0/bootstrap-table.min.js"></script>
    <script src="${ctx}/bootstrap-table/1.12.0/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="${ctx}/bootstrap-table/1.12.0/extensions/export/bootstrap-table-export.min.js"></script>
    <script src="${ctx}/js/extends.js"></script>
    <script src="${ctx}/layui/layui.all.js"></script>
    <script src="${ctx}/js/util.js"></script>
    <link href="${ctx}/layui/css/layui.css" rel="stylesheet">
</head>
<title>统计浏览赚</title>
<div class="lay-box">
    <form class="layui-form" action="" style="margin-top: 10px">
<#--      <div class="layui-inline">-->
<#--            <label class="layui-form-label" style="width: 120px">重新统计日期</label>-->
<#--            <div class="layui-input-inline">-->
<#--                <input type="text" class="layui-input" id="last" placeholder="请选择时间">-->
<#--            </div>-->
<#--        </div>-->
        <div class="layui-inline" style="margin: 0 0 8px 20px;">
            <label class="layui-form-label" style="width: 95px">起始时间</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="star" placeholder="请选择时间">
            </div>
        </div>
        <div class="layui-inline" style="margin: 0 0 8px 20px;">
            <label class="layui-form-label" style="width: 95px">结束时间</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="end" placeholder="请选择时间">
            </div>
        </div>

        <div class="input-group" style="float: left; width: 300px;margin:0 20px 10px 0;">
            <span class="input-group-addon">渠道</span>
            <input type="text" class="form-control" id="likeBrand">
        </div>
<#--        <div style="width: 150px;display: inline-block;margin: 0 0 8px 20px;">-->
<#--            <select name="category" id="category" lay-verify="" style="width:300px">-->
<#--                <option value=2 >全部用户</option>-->
<#--                <option value=0 >老用户</option>-->
<#--                <option value=1>新用户</option>-->
<#--            </select>-->
<#--        </div>-->

    </form>
<#--    <button class="layui-btn" onclick="lastCheck()" style="float: left;margin-left:20px">-->
<#--        <i class="layui-icon">&#xe669;</i> 统计日期-->
<#--    </button>-->
   <#-- <button class="layui-btn" onclick="exportExcel()" style="float: left;margin-left:20px">
        <i class="layui-icon">&#xe669;</i> 导出
    </button>-->
    <span onclick="search()" class="btn btn-info" style="height: 38px;margin-left: 10px;font-size: 14px">查询</span>
<#--    <br>-->
<#--    <span style="margin-left: 1%;">1、每列展示内容为：点击量/完成量/完成率-->
<#--        2、点击量只保存最近3天数据</span>-->
    <table class="table table-border table-bordered table-hover table-bg table-sort" id="layTable"
           lay-filter="tableFilter">

    </table>
</div>

<style>
    .lay-box {
        padding: 8px 12px;
    }

    .layui-form-checkbox[lay-skin=primary] i {
        top: 5px;
    }
</style>
<#--<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>-->


<!--请在下方写此页面业务相关的脚本-->
<script type="text/html" id="switchTpl">
    <!-- 这里的 checked 的状态只是演示 -->
    <input type="checkbox" name="sex" value="{{d.id}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="sexDemo" {{
           d.enable== 1 ? 'checked' : '' }}>
</script>

<script type="text/javascript">
    var category=2;
    function lastCheck(){
        var last = $("#last").val();
        $.ajax({
            url: "/sys/cences/cencesnewhand/lastCheck",
            type: 'post',
            data: {date: last},
            async: true,
            dataType: "json",
            success: function (arg) {
                if (arg) {
                    layer.msg(arg.message);
                    search();
                } else {
                    layer.msg(arg.message);
                }
            }
        });
    }

    function exportExcel(){
        var typee;
        var star = $("#star").val();
        var end = $("#end").val();
        var appStore = $("#appStore").val();
        var category = $("#category").val();
        if(appStore!=="all"){
            typee=0;
        }else {
            typee=1;
        }

        location.href="/sys/cences/cencesnewhand/export?star="+star+"&end="+end+"&appStore="+appStore+"&category="+category+"&type="+typee;

        // $.ajax({
        //     url: "/sys/cences/cencesnewhand/export",
        //     type: 'post',
        //     data: {star: star, end: end, appStore: appStore, category: category,type:type,configId:configId},
        //     async: true,
        //     dataType: "json",
        //     success: function (arg) {
        //         if (arg) {
        //             layer.msg(arg.message);
        //             //search();
        //         } else {
        //             layer.msg(arg.message);
        //         }
        //     }
        // });

    }
    layui.use('laydate', function () {
        var laydate = layui.laydate;
        laydate.render({
            elem: '#star'
            , type: 'datetime'
            , format: 'yyyyMMdd'

        });
        laydate.render({
            elem: '#end'
            , type: 'datetime'
            , format: 'yyyyMMdd'
        });
        laydate.render({
            elem: '#last'
            , type: 'date'
            ,format: 'yyyy-MM-dd'
        });
    });
    var startDate = "";
    var endDate = "";
    var searchKey = "";
    var tableIns;
    var ids = "";
    var form;
    var table = "cences_master";
    layui.use('table', function () {
        tableIns = layui.table,
            form = layui.form;
        form.render();
        tableIns.render({
            elem: '#layTable'
            ,
            url: '/sys/cences/cencesnewhand/appstorepage'

            , done: function(res, curr, count){
                //如果是异步请求数据方式，res即为你接口返回的信息。
                //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
                console.log(res);

                //得到当前页码
                console.log(curr);

                //得到数据总量
                console.log(count);
            },
            method: 'POST'
            ,
            where: {
            }
            ,
            toolbar:true, toolbar:true,
            id: 'dataTableId'
            ,
            cols: [[
                {type: 'checkbox', field: 'id'}
                , {
                    field: 'time',
                    title: '记录日期',
                    width: 150,
                    align: 'center',
                    sort: true,
                    templet: function (data) {
                        if(data.time<0){
                            return '统计';
                        }else {
                            var str = data.time+'';
                            return str.substr(0,4)+"-"+str.substr(4,2)+"-"+str.substr(6,2);
                        }
                    }
                }
                , {
                    field: 'finishNum',
                    title: '3元红包',
                    width: 150,
                    align: 'center',
                    sort: true,
                    templet: function (data) {
                        return data.finishNum?data.finishNum:0;
                    }
                }
                , {
                    field: 'earnwayFinishNum',
                    title: '赚钱攻略',
                    width: 150,
                    align: 'center',
                    sort: true,
                    templet: function (data) {
                        return data.earnwayFinishNum?data.earnwayFinishNum:0;
                    }
                }
                , {
                    field: 'installFinishNum',
                    title: '开安装权限',
                    width: 150,
                    align: 'center',
                    sort: true,
                    templet: function (data) {
                        return data.installFinishNum?data.installFinishNum:0;
                    }
                } , {
                    field: 'accessFinishNum',
                    title: '开访问权限',
                    width: 150,
                    align: 'center',
                    sort: true,
                    templet: function (data) {
                        return data.accessFinishNum?data.accessFinishNum:0;
                    }
                }
                , {
                    field: 'pushFinishNum',
                    title: '开推送权限',
                    width: 150,
                    align: 'center',
                    sort: true,
                    templet: function (data) {
                        return data.pushFinishNum?data.pushFinishNum:0;
                    }
                }
                , {
                    field: 'earndayFinishNum',
                    title: '每日必赚',
                    width: 150,
                    align: 'center',
                    sort: true,
                    templet: function (data) {
                        return data.earndayFinishNum?data.earndayFinishNum:0;
                    }
                }
                , {
                    field: 'walkFinishNum',
                    title: '走路赚',
                    width: 150,
                    align: 'center',
                    sort: true,
                    templet: function (data) {
                        return data.walkFinishNum?data.walkFinishNum:0;
                    }
                }


            ]]
            ,
            page: true
        });

        form.on('switch(sexDemo)', function (obj) {
            // layer.tips(this.value + ' ' + this.name + '：'+ obj.elem.checked, obj.othis);
            if (obj.elem.checked) {
                commonenable(this.value, 1);
            } else {
                commonenable(this.value, 0);
            }

        });
        tableIns.on('checkbox(tableFilter)', function (obj) {
            var checkStatus = tableIns.checkStatus('dataTableId');
            var dataList = checkStatus.data;
            if (dataList != null && dataList.length > 0) {

                for (var i = 0; i < dataList.length; i++) {
                    ids += dataList[i].id + ",";
                }
            }
        });


        tableIns.on('tool(tableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'detail') {
                layer.msg('ID：' + data.id + ' 的查看操作');
            } else if (obj.event === 'del') {
                layer.confirm('真的删除行么', function (index) {
                    deleteId(data.id)
                    layer.close(index);
                });
            } else if (obj.event === 'edit') {
                layer_show("修改", "/sys/cencesoutlay/edit?id=" + data.id, "650", "650");
                parent.search();
            }
        });
    });

    function search() {
        var star = $("#star").val();
        var end = $("#end").val();

        if(!star || !end){
            layer.msg("请选择时间");
            return;
        }
        if(!$("#likeBrand").val()){
            layer.msg("请输入渠道");
            return;
        }


        tableIns.reload('dataTableId', {
            where: {likeBrand:$("#likeBrand").val(),star: star,end: end},
            page: {
                curr: 1
            }
        });
    }




    function showmsg(msg) {
        layer.msg(msg)
    }

</script>
<!--/请在上方写此页面业务相关的脚本-->
